package de.fme.tracking;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;

/**
 * @author PloetzJ
 * Feedback User DAO
 */

public class UserEntity {

    // JSON keys
    public static final String KEY_ID = "id";
    public static final String KEY_NAME = "name";
    public static final String KEY_CHANNEL_UUID = "pubChannelUuid";
    public static final String KEY_SCREEN_NAME = "screenName";
    public static final String KEY_PROFILE_ID = "profileId";
    public static final String KEY_PROFILE_URL = "profileUrl";
    public static final String KEY_PROFILE_PICTURE_URL = "profilePictureUrl";
    public static final String KEY_FOLLOWER_COUNT = "followersCount";
    public static final String KEY_LATITUDE = "latitude";
    public static final String KEY_LONGITUDE = "longitude";
    
    private Long id; // internal DB-generated id
    private String name;
	private String pubChannelUuid;
    private String screenName;
    private String profileId;
    private String profileUrl;
    private String profilePictureUrl;
    private Integer followersCount;
    private Double latitude; //52.2875
    private Double longitude; //10.57528
    
    
    public UserEntity(String name, String pubChannelUuid, String screenName,
			String profileId, String profileUrl, String profilePictureUrl,
			Integer followersCount, Double latitude, Double longitude) {
		super();
		this.name = name;
		this.pubChannelUuid = pubChannelUuid;
		this.screenName = screenName;
		this.profileId = profileId;
		this.profileUrl = profileUrl;
		this.profilePictureUrl = profilePictureUrl;
		this.followersCount = followersCount;
		this.latitude = latitude;
		this.longitude = longitude;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the channelId
	 */
	public String getChannelUuid() {
		return pubChannelUuid;
	}

	/**
	 * @param channelId the channelId to set
	 */
	public void setChannelUuid(String channelId) {
		this.pubChannelUuid = channelId;
	}

	/**
	 * @return the screenName
	 */
	public String getScreenName() {
		return screenName;
	}

	/**
	 * @param screenName the screenName to set
	 */
	public void setScreenName(String screenName) {
		this.screenName = screenName;
	}

	/**
	 * @return the profileId
	 */
	public String getProfileId() {
		return profileId;
	}

	/**
	 * @param profileId the profileId to set
	 */
	public void setProfileId(String profileId) {
		this.profileId = profileId;
	}

	/**
	 * @return the profileUrl
	 */
	public String getProfileUrl() {
		return profileUrl;
	}

	/**
	 * @param profileUrl the profileUrl to set
	 */
	public void setProfileUrl(String profileUrl) {
		this.profileUrl = profileUrl;
	}

	/**
	 * @return the profilePictureUrl
	 */
	public String getProfilePictureUrl() {
		return profilePictureUrl;
	}

	/**
	 * @param profilePictureUrl the profilePictureUrl to set
	 */
	public void setProfilePictureUrl(String profilePictureUrl) {
		this.profilePictureUrl = profilePictureUrl;
	}

	/**
	 * @return the followersCount
	 */
	public Integer getFollowersCount() {
		return followersCount;
	}

	/**
	 * @param followersCount the followersCount to set
	 */
	public void setFollowersCount(Integer followersCount) {
		this.followersCount = followersCount;
	}

	/**
	 * @return the latitude
	 */
	public Double getLatitude() {
		return latitude;
	}

	/**
	 * @param latitude the latitude to set
	 */
	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	/**
	 * @return the longitude
	 */
	public Double getLongitude() {
		return longitude;
	}

	/**
	 * @param longitude the longitude to set
	 */
	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

    public Map<String, Object> getModel() throws JSONException
    {
        Map<String, Object> map = new HashMap<String, Object>();
        
        map.put(KEY_ID, id);
        
        map.put(KEY_NAME, getName());
        map.put(KEY_CHANNEL_UUID, getChannelUuid());
        
        if (getScreenName() != null) { map.put(KEY_SCREEN_NAME, getScreenName()); }
        map.put(KEY_PROFILE_ID, getProfileId());
        map.put(KEY_PROFILE_URL, getProfileUrl());
        map.put(KEY_PROFILE_PICTURE_URL, getProfilePictureUrl());
        
        map.put(KEY_FOLLOWER_COUNT, getFollowersCount());
        
        if ((getLatitude() != 0) && (getLongitude() != 0))
        {
            map.put(KEY_LATITUDE, getLatitude());
            map.put(KEY_LONGITUDE, getLongitude());
        }
        
        return map;
    }



	public void setName(String name) {
		this.name = name;
	}



	public String getName() {
		return name;
	}

}